from abc import ABC, abstractmethod

# 抽象产品接口
class AbstractProduct(ABC):
    @abstractmethod
    def use(self):
        pass

# 具体产品1类
class ConcreteProduct1(AbstractProduct):
    def use(self):
        return "Using ConcreteProduct1"

# 具体产品2类
class ConcreteProduct2(AbstractProduct):
    def use(self):
        return "Using ConcreteProduct2"

# 抽象工厂接口
class AbstractFactory(ABC):
    @abstractmethod
    def create_product(self):
        pass

# 具体工厂1类
class ConcreteFactory1(AbstractFactory):
    def create_product(self):
        return ConcreteProduct1()

# 具体工厂2类
class ConcreteFactory2(AbstractFactory):
    def create_product(self):
        return ConcreteProduct2()

# 客户端代码
class Client:
    def __init__(self, factory: AbstractFactory):
        self.factory = factory
        self.product = factory.create_product()

    def run(self):
        return self.product.use()

# 测试代码
if __name__ == "__main__":
    factory1 = ConcreteFactory1()
    client1 = Client(factory1)
    print(client1.run())  # 输出: Using ConcreteProduct1

    factory2 = ConcreteFactory2()
    client2 = Client(factory2)
    print(client2.run())  # 输出: Using ConcreteProduct2